﻿using BCCommon;
using BCDto.Common.ErrorMessage;
using BCDto.Common.Wallet;
using BCService.Common.Wallet;
using Microsoft.AspNetCore.Mvc;

namespace BCTMSRESTful.Controllers.DriverApp.Wallet
{
    /// <summary>
    /// 用户钱包提现
    /// </summary>
    [ApiExplorerSettings(GroupName = "DriverApp")]
    [Route("api/v1/DriverApp/[controller]")]
    public class WalletTransferController : DriverAppBaseController
    {
        private readonly IWalletTransferService walletTransferService;

        public WalletTransferController(IWalletTransferService walletTransferService)
        {
            this.walletTransferService = walletTransferService;
        }

        /// <summary>
        /// 创建提现申请
        /// </summary>
        /// <param name="requestDto"></param>
        /// <response code="200">返回用户提现信息</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpPost]
        [ProducesResponseType(typeof(WalletTransferDto), 200)]
        [ProducesResponseType(typeof(ErrorMessageDto), 400)]
        [ProducesResponseType(typeof(ErrorMessageDto), 500)]
        public IActionResult Post([FromBody]WalletTransferRequestDto requestDto)
        {
            var walletTransferDto = walletTransferService.Create(requestDto, this.UserInfo);
            return Ok(walletTransferDto);
        }

        /// <summary>
        /// 获取用户提现记录
        /// </summary>
        /// <response code="200">返回用户提现信息</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet]
        [ProducesResponseType(typeof(PageableList<WalletTransferDto>), 200)]
        [ProducesResponseType(typeof(ErrorMessageDto), 400)]
        [ProducesResponseType(typeof(ErrorMessageDto), 500)]
        public IActionResult UserWalletTransfer(
            [FromQuery(Name = "index")] int? pageIndex = 1,
            [FromQuery(Name = "size")] int? pageSize = 10)
        { 
            return Ok(this.walletTransferService.GetUserWalletTransfer(UserInfo.UserId, pageIndex.Value, pageSize.Value));
        }
    }
}